home *** CD-ROM | disk | FTP | other *** search
- ;/* Execute me to compile with DICE V3.0
- dcc popwindow.c -proto -mi -ms -mRR -lbgui
- quit
- */
- /*
- ** $RCSfile: popwindow.c,v $
- ** Description: Simple demonstration of jumping to another screen.
- ** Copyright: (C) Copyright 1994 Jaba Development.
- ** (C) Copyright 1994 Jan van den Baard.
- ** All Rights Reserved.
- **
- ** $Author: jaba $
- ** $Revision: 1.2 $
- ** $Date: 1994/09/23 11:29:18 $
- **/
-
- #include <libraries/bgui.h>
- #include <libraries/bgui_macros.h>
- #include <libraries/gadtools.h>
-
- #include <clib/alib_protos.h>
-
- #include <proto/exec.h>
- #include <proto/bgui.h>
- #include <proto/intuition.h>
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- /*
- ** Library base pointer.
- ** NOTE: The intuition.library is opened by DICE
- ** it's auto-init code.
- **/
- struct Library *BGUIBase;
-
- /*
- ** Object ID's.
- **/
- #define ID_QUIT 1
- #define ID_SCREENNAME 2
-
- int main( int argc, char *argv[] )
- {
- struct Window *window;
- Object *WO_Window, *GO_Quit, *GO_Name;
- UBYTE name[ 64 ];
- ULONG signal = 0, rc, tmp;
- BOOL running = TRUE;
-
- /*
- ** Open the library.
- **/
- if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION )) {
- /*
- ** Create the window object.
- **/
- WO_Window = WindowObject,
- WINDOW_Title, "PopWindow Demo",
- WINDOW_ScaleWidth, 20,
- WINDOW_SizeGadget, FALSE,
- WINDOW_PubScreenName, "Workbench",
- WINDOW_HelpFile, "S:User-Startup",
- WINDOW_HelpNode, "Main",
- WINDOW_MasterGroup,
- VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ),
- StartMember, GO_Name = String( "Screen Name:", "Workbench", 64, ID_SCREENNAME ), EndMember,
- StartMember,
- HGroupObject,
- VarSpace( 50 ),
- StartMember, GO_Quit = KeyButton( "_Quit", ID_QUIT ), EndMember,
- VarSpace( 50 ),
- EndObject,
- EndMember,
- EndObject,
- EndObject;
-
- /*
- ** Object created OK?
- **/
- if ( WO_Window ) {
- /*
- ** Assign a key to the button.
- **/
- tmp = GadgetKey( WO_Window, GO_Quit, "q" );
- /*
- ** OK?
- **/
- if ( tmp ) {
- /*
- ** try to open the window.
- **/
- if ( window = WindowOpen( WO_Window )) {
- /*
- ** Obtain it's wait mask.
- **/
- GetAttr( WINDOW_SigMask, WO_Window, &signal );
- /*
- ** Event loop...
- **/
- do {
- Wait( signal );
- /*
- ** Handle events.
- **/
- while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
- /*
- ** Evaluate return code.
- **/
- switch ( rc ) {
-
- case WMHI_CLOSEWINDOW:
- case ID_QUIT:
- running = FALSE;
- break;
-
- case ID_SCREENNAME:
- /*
- ** Obtain screen name.
- **/
- GetAttr( STRINGA_TextVal, GO_Name, &tmp );
- /*
- ** Save it.
- **/
- strcpy( name, ( UBYTE * )tmp );
- /*
- ** Close the window.
- **/
- WindowClose( WO_Window );
- /*
- ** Setup name.
- **/
- SetAttrs( WO_Window, WINDOW_PubScreenName, name, TAG_END );
- /*
- ** Re-open window.
- **/
- if ( window = WindowOpen( WO_Window )) {
- /*
- ** Re-set signal mask.
- **/
- signal = 0L;
- GetAttr( WINDOW_SigMask, WO_Window, &signal );
- /*
- ** Show it in the gadget.
- **/
- SetGadgetAttrs(( struct Gadget * )GO_Name, window, NULL, STRINGA_TextVal, name, TAG_END );
- } else {
- puts( "Can't re-open the window!" );
- goto bye;
- }
- break;
- }
- }
- } while ( running );
- } else
- puts ( "Could not open the window" );
- } else
- puts( "Could not assign gadget keys" );
- bye:
- /*
- ** Disposing of the window object will
- ** also close the window if it is
- ** already opened and it will dispose of
- ** all objects attached to it.
- **/
- DisposeObject( WO_Window );
- } else
- puts( "Could not create the window object" );
- CloseLibrary( BGUIBase );
- } else
- puts( "Unable to open the bgui.library" );
-
- return( 0 );
- }
-
- #ifdef _DCC
- int wbmain( struct WBStartup *wbs )
- {
- return( main( 0, NULL ));
- }
- #endif
-